home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / rawkey-0.2 / rawkey-0 / rawkey / rawkey.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-24  |  3.0 KB  |  102 lines

  1. /* librawkey v0.2 - (c) 1994 Russell Marks
  2.  * This library may be freely used/copied/modified provided this copyright
  3.  * notice is left intact.
  4.  */
  5.  
  6.  
  7. /* scancodes from Pink Shirt book */
  8.  
  9. /* random keys not convered anywhere else below */
  10. #define ESCAPE_KEY    0x01
  11. #define ENTER_KEY    28
  12. #define BACKSPACE    14
  13. #define TAB_KEY        15
  14.  
  15. /* shifts */
  16. #define LEFT_SHIFT    0x2A
  17. #define RIGHT_SHIFT    0x36
  18. #define LEFT_CTRL    0x1D
  19. #define LEFT_ALT    0x38
  20.  
  21. /* NB: right ctrl sends 0xE0 then LEFT_CTRL, right alt sends 0xE0 then
  22.  * LEFT_ALT. If you want to do any shift handling, you probably want to
  23.  * just ignore 0xE0, and look for LEFT_CTRL and LEFT_ALT.
  24.  * note that using scan_keyboard() and is_key_pressed() does this for you.
  25.  */
  26.  
  27. /* function keys */
  28.  
  29. /* this macro lets you do things like FUNC_KEY(1), FUNC_KEY(2), etc. up to
  30.  * FUNC_KEY(12).
  31.  * don't use any side-effects with it.
  32.  */
  33. #define FUNC_KEY(z)    (0x3A+(z)+((z)>10)?18:0)
  34.  
  35. /* cursors, pgup, pgdn, etc. */
  36.  
  37. #define CURSOR_LEFT    0x4B
  38. #define CURSOR_RIGHT    0x4D
  39. #define CURSOR_UP    0x48
  40. #define CURSOR_DOWN    0x50
  41. #define KEYPAD_CENTER    0x4C    /* the '5' in the centre of the keypad */
  42.  
  43. #define INSERT_KEY    0x52
  44. #define DELETE_KEY    0x53
  45. #define HOME_KEY    0x47
  46. #define END_KEY        0x4F
  47. #define PAGE_UP        0x49
  48. #define PAGE_DOWN    0x51
  49.  
  50. /* NB: the 'grey' cursors, pgup, pgdn etc. generate 0xE0 before sending the
  51.  * above codes. The easiest way to deal with this is to ignore 0xE0. :)
  52.  */
  53.  
  54. #define CAPS_LOCK    0x3A
  55. #define NUM_LOCK    0x45
  56. #define SCROLL_LOCK    0x46
  57.  
  58. /* PrintScreen generates E0, 2A, E0, 37.    (0x63?)
  59.  * Pause generates E1, 10, 45.            (0x77?)
  60.  * I leave it up to you how to figure those two out properly,
  61.  * but the easiest way is to ignore them. :-/
  62.  */
  63.  
  64. #define GRAY_PLUS    0x4E
  65. #define GRAY_MINUS    0x4A
  66. #define GRAY_MULTIPLY    0x37    /* NB: also gen'd by PrtSc, see above */
  67. #define GRAY_DIVIDE    0x36    /* NB: prefixed by 0xE0 */
  68.  
  69.  
  70.  
  71. /* for most other keys, you should use the keymap_trans() function to
  72.  * convert the scancode to whatever the keymap would normally generate.
  73.  */
  74.  
  75.  
  76.  
  77. /* prototypes */
  78.  
  79. /* NB: it is *vital* that you call rawmode_exit() when you finish, or
  80.  * else you'll be left with the keyboard translation in RAW mode! Not Good.
  81.  * Consider setting up a SIGSEGV handler that calls it, etc. just in case.
  82.  */
  83.  
  84. extern int rawmode_init();        /* call this to start */
  85. extern void rawmode_exit();        /* call this to end */
  86.  
  87. extern int is_key_pressed(int sc);
  88. extern void scan_keyboard();
  89.  
  90. extern int get_scancode();    /* returns scancode or -1 if no key pressed */
  91. extern int keymap_trans(int sc); /* effectively translates scancode to ASCII */
  92. extern int scancode_trans(int asc); /* effectively xlates ASCII to scancode */
  93.  
  94. /* call like: set_switch_functions(undrawfunc,redrawfunc);
  95.  * where undrawfunc() puts the screen in text mode, and
  96.  *       redrawfunc() goes back to graphics and redraws the screen.
  97.  * after the above call, you can do allow_switch(1); to enable
  98.  * VC switching.
  99.  */
  100. extern void set_switch_functions(void (*off)(void),void (*on)(void));
  101. extern void allow_switch(int on); /* allow VT switch if on=1 */
  102.